<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,height=device-height, user-scalable=no,initial-scale=1, minimum-scale=1, maximum-scale=1">
   <title>API说明</title>
   <link href="/admin/css/bootstrap.min.css" rel="stylesheet">
   <script src="/ueditor/third-party/jquery-1.10.2.min.js"></script>
   <script src="/admin/js/bootstrap.min.js"></script>
</head>
<body style="max-width: 1000px;margin: auto;">
<div style="width: 100%;height: 60px;">
    <div style="margin: auto;float: right;margin-top: 20px;">
        {% for n, d in type %}
            <a href="?type={{ n }}" class="btn btn-default">{{ n }}</a>
        {% endfor %}
    </div>
</div>
<div style="width:25%;float: left;<!-- position: fixed; -->">
    <ul class="nav nav-pills nav-stacked" id="myTab"> 
        {% for n, d in data %}
            <li><a class="bb" href="?type={{d.type}}&ids={{d.iurl}}" dis="a{{ d.name }}" url="{{ d.iurl }}" >
                {{d.name}}
            </a></li> 
        {% endfor %}
    </ul> 
    <a class="btn btn-primary" style="display: block;height: 40px;line-height: 40px;width: 100%;text-align: 40px;" href="/api/doc/">返回</a>
</div>
       
<div class="tab-content" style="width:73%;float: right;margin-bottom: 50px;"> 
{% for n, d in data %}
    <div class="tab-pane" id="a{{ d.name }}">
        <div style="">
            <div style="width: 100%">
                <b>接口名</b>
            </div>
            <div class="alert alert-success">
                {{ d.name }}
            </div>
        </div>
            <div style="width: 100%">
                <b>接口版本</b>
            </div>
            <div class="alert alert-info">
                {% for i, j in type %}
                    {% if d.type == i %}
                        <span style="color:red;">当前：{{ i }}，</span>
                    {% else %}
                        <span><a href="?type={{i}}&ids={{ d.iurl }}">{{ i }}</a>，</span>
                    {% endif %}
                {% endfor %}
            </div>
            <div style="width: 100%">
                <b>接口描述</b>
            </div>
            <div class="alert alert-info">
                {{ d.bewrite }}
            </div>
            <div style="width: 100%">
                <b>请求类型及路径</b>
            </div>
            <div class="alert alert-info">
                http://{{ d.host }}{{ d.url }}
            </div>
            <div style="width: 100%">
                <b>请求示例</b>
            </div>
            <div class="alert alert-info">
                【{{ d.method }}】http://{{ d.host }}{{ d.url }}{%if d.field%}?{%endif%}{% for i, j in d.field %}{{i}}={{j.0}}&{% endfor %}
            </div>
                <div>
                    <table class="table table-hover">
                        <caption><b>参数说明</b></caption>
                        <thead>
                          <tr>
                             <th>参数名称</th>
                             <th>参数说明</th>
                             <th>备注</th>
                          </tr>
                        </thead>
                        <tbody>
                            {% for i, j in d.field %}
                                <tr>
                                    <td>{{ i }}</td>
                                    {% for x, y in j %}
                                        <td>{{ y }}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            <div style="width: 100%">
                <b>返回</b>
            </div>
            <div class="alert alert-info">
                {status:200, message:"", data:""}
            </div>
                <div>
                    <table class="table table-hover">
                        <caption><b>返回值说明(data)</b></caption>
                        <thead>
                          <tr>
                             <th>返回值名称</th>
                             <th>返回值说明</th>
                             <th>备注</th>
                          </tr>
                        </thead>
                        <tbody>
                            {% for i, j in d.return %}
                                <tr>
                                    <td>{{ i }}</td>
                                    {% for x, y in j %}
                                        <td>{{ y }}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                <div>
                    <table class="table table-hover">
                        <caption><b>返回值代码(status)</b></caption>
                        <thead>
                          <tr>
                             <th>返回代码名称</th>
                             <th>返回代码说明</th>
                             <th>备注</th>
                          </tr>
                        </thead>
                        <tbody>
                            {% for i, j in d.returncode %}
                                <tr>
                                    <td>{{ i }}</td>
                                    {% for x, y in j %}
                                        <td>{{ y }}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
    </div> 
{% endfor %}
</div> 
       
<script> 
  $(function () { 
    $('#myTab a').click(function (e) { 
      // e.preventDefault();//阻止a链接的跳转行为 
      $(".tab-pane").hide()
      $("#"+$(this).attr('dis')).show()
      // $(this).tab('show');//显示当前选中的链接及关联的content 
    }) 
  }) 
//get参数获取
function request(paras) {
    var url = location.href;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {}
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof (returnValue) == "undefined") {
        return "";
    } else {
        //t=new String(returnValue.getBytes("ISO8859_1"),"UTF-8");
        //return t;
        return returnValue;
    }
}
$(document).ready(function(){
    if(request("ids")!=""){
        count = 0;
        $('.bb').each(function(){
            if($(this).attr('url')==request("ids").replace(new RegExp("%2f","g"),'/')){
                $(this).click();
                count = 1;
            }
        })
        if (count==0){
            if(confirm("该接口无此版本更新，是否回到上个页面")){
                history.go(-1)
            }
        }
    }
});
</script>

</body>
</html>
